package com.itheima.mapper;

import com.itheima.domain.Classes;
import com.itheima.domain.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface ClassesMapper {
    @Select("select * from classes")
    @Results({
            @Result(column = "cid" ,property = "id" ,id =true),
            @Result(column = "cname" ,property = "name"),
            @Result(
                    javaType = List.class,
                    property = "students",
                    column = "cid",
                    many = @Many(select = "com.itheima.mapper.StudentMapper.findBySid",fetchType = FetchType.LAZY)
            )
    })
    List<Classes> findAll();
}
